package cn.steel.domain.entity;

import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
public class SupplierInfo implements Serializable {
    private Long id;
    private Long userId;
    private String company;
    private String phone;
    private String address;
    private String description;
    private String logoUrl;
    private String licenseUrl;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    private Double averageRating;
    private String auditStatus;
    // 新增字段：整数星数和是否有半星
    private Integer fullStars;
    private Boolean hasHalfStar;

    // 计算星级的方法
    public void calculateStars() {
        if (averageRating == null) {
            this.fullStars = 0;
            this.hasHalfStar = false;
            return;
        }
        this.fullStars = (int) Math.floor(averageRating);
        this.hasHalfStar = (averageRating % 1) >= 0.5;

    }
}